
@extends ('layouts/app')

@section('content')
    <div class="weui-pay append">
        <form action="" id="info" name="info">
            @csrf
            <div class="site weui-cells_checkbox">
                <div class="weui-cell ">
                    <div class="weui-cell__hd">
                        <label for="name">支付密码:</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input type="password" maxlength="6" class="weui-input" name="payword" placeholder="">
                    </div>
                </div>
            </div>

            <div class="site weui-cells_checkbox">
                <div class="weui-cell ">
                    <div class="weui-cell__hd">
                        <label for="name">确认密码:</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input type="password" maxlength="6" class="weui-input" name="cpayword" placeholder="">
                    </div>

                </div>
            </div>
            <div class="demos-content-padded">
                <a href="javascript:;" class="weui-btn weui-btn_blue open-popup">确认</a>
            </div>
        </form>
    </div>
    <script>

        $(".open-popup").click(function () {
            var payword = $("input[name='payword']").val(),
                cpayword = $("input[name='cpayword']").val();

                console.log("payword", payword);
            var info = InputStrategy.check("isNumber", payword);

            if (info) {
                return $.toast(info, "text");
            }

            if (payword !== cpayword) {
                return $.toast("两次输入的密码不一致！", "text");
            }

            save("/api/user/setpayword", "#info", function (res) {
                if (typeof res === 'string') {
                    res = JSON.parse(res);
                }
                history.go(-1);
                $.alert(res.info);
            });

        });
    </script>
@endsection
